﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TireBias.Models.BIASPLANModel.BIASPLAN_DS>" %>


<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
  
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  <script src="<%: Url.Content("~/Scripts/Report/UseData.js") %>" type="text/javascript"></script>
  <style type="text/css">
     .col
{
   padding-left:  100px !important; 
   
   width: 25%; 
   text-align: left !important;
   background-color:#ccc !important;
}
.cell
{
    line-height:40px!important;
}
  .chk
  {
     width:200px !important; 
     height:75px!important;       
     cursor:pointer;      
     border:1px solid #999!important;
     margin:5px;
         
  }
  .active
  {
     background-color:Orange !important;
     border:none !important;
     color:White;
  }
      #txtInputA, #txtInputB
      {
         font-size: 1em;
         height: 2em;
         line-height: 2.5em;
         width: 90%;
      }
      .nomat
      {
         color:Red !important;
      }
   </style>

   <table class="shadow" style="width: 94%">
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._Text))
         {%>
      <tr>        
         <td colspan="3" class="cell" style="font-size: x-large; margin-left: 5%; line-height: 35px;
            padding: 5px; background-color: #C38DEC;color:White">
           <%= Model._Text%>
         </td>
      </tr>
      <%} %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 50%; vertical-align:top;"  rowspan="12">            
         <table id="tbl1" width="98%">
         <tr class="rowa cell" id="rowh">
            <td class="head" colspan="2" >USE 
            USE PLY PLAN <span class="fontTh">ใช้แผนการตัดผ้าใบ</span></td>
         </tr>    
         <tr  class="rowb cell"  ><td style="line-height:40px!important;border:1px solid #000; width:40%"  >
               KANBAN</td> <td style="line-height:40px!important;border:1px solid #000" >Actual</td> </tr>  
            <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P1))
            { %>     <tr  class="rowa cell"  ><td style="line-height:40px!important;border:1px solid #000; width:40%"  >P1</td> 
                 <td style="line-height:40px!important;border:1px solid #000" id="sumP1" >&nbsp;</td> </tr>       <%} %>
            <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P2))
            { %><tr  class="rowa cell" ><td style="line-height:40px!important;border:1px solid #000;  width:40%">P2</td> 
                 <td style="line-height:40px!important;border:1px solid #000" id="sumP2" >&nbsp;</td> </tr>       <%} %>
            <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P3))
            { %><tr class="rowa cell" ><td style="line-height:40px!important;border:1px solid #000; width:40%" >P3</td> 
                 <td style="line-height:40px!important;border:1px solid #000" id="sumP3" > &nbsp;</td> </tr>       <%} %>
            <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P4))
            { %><tr  class="rowa cell" ><td style="line-height:40px!important;border:1px solid #000; width:40%" >P4</td> 
                 <td  style="line-height:40px!important;border:1px solid #000" id="sumP4" >&nbsp;</td> </tr>       <%} %>
            <tr class="rowa cell" style="background-color:#20B2AA">
               <td style="line-height: 40px!important; border: 1px solid #000; width: 40%">
                   TOTAL</td>
               <td style="line-height: 40px!important; border: 1px solid #000" id="total">
                   &nbsp;</td>
            </tr> 
         </table>
         <br />

            <table id="tbl2" width="98%">
         <tr class="rowa cell">
         <td class="head" colspan="5" >Choose 
           CHOOSE PLY PLAN <span class="fontTh">เลือกแผนการตัดผ้าใบ</span></td>
         </tr>
         <tr id="ch" class="rowb head" style="border:1px solid">
            <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P1))
               { %><td style="line-height:40px!important;border:1px solid #000" class="cell">P1</td>         <%} %>
         <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P2))
               { %><td style="line-height:40px!important;border:1px solid #000" class="cell">P2</td>         <%} %>
         <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P3))
               { %><td style="line-height:40px!important;border:1px solid #000" class="cell">P3</td>         <%} %>
          <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P4))
               { %><td style="line-height:40px!important;border:1px solid #000" class="cell">P4</td>         <%} %>
         </tr>
                  <tr id="Tr1" class="rowa head" style="border:1px solid">
            <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P1))
               {     %>
                <td>
             <%  for(int i=0; i< Convert.ToInt16(Model.cP1); i++) {
               %>
              <input  type="button" class="chk" value="P1"  /><br />

         <%  } %>
            </td> 
              <% } if (WinNemoLib.StrUtil.IsNotEmpty(Model.cP2))
                 {     %>
                <td>
             <%  for(int i=0; i< Convert.ToInt16(Model.cP2); i++) {
               %>
            <input  type="button" class="chk" value="P2"  /><br />

         <%  } %>
            </td> 
              <% } if (WinNemoLib.StrUtil.IsNotEmpty(Model._P3))
                 {     %>
                <td>
             <%  for(int i=0; i< Convert.ToInt16(Model.cP3); i++) {
               %>
             <input  type="button" class="chk" value="P3"  /><br />

         <%  } %>
            </td> 
              <% } if (WinNemoLib.StrUtil.IsNotEmpty(Model._P4))
                    {     %>
                <td>
             <%  for(int i=0; i< Convert.ToInt16(Model.cP4); i++) {
               %>
          <input  type="button" class="chk" value="P4"  /><br /><br />

         <%  } %>
            </td> 
              <% }%> 
         </tr>
         </table>
            </td>
         <td class="col" style="p width: 25%;">
            DATE-SEQ
            <span class="fontTh">ล็อตที่ผลิต</span>
         </td>
         <td class="cell" id="seqDT">
       <h3><%= Model._Plandt %>-<%=Model._Itemno %></h3>  
         </td>
      </tr>
      <tr class="rowb">
         <td class="col" style="p width: 25%;">
            SIZE
            <span class="fontTh">ขนาดผ้าใบ</span>
         </td>
         <td class="cell" id="Td1">
         <h3> <%= Model._Size %></h3>  
         </td>
      </tr>
      <tr class="rowb">
         <td class="col" style="p width: 25%;">
            FORMING
           
            <span class="fontTh">เครื่องที่สร้าง</span>
         </td>
         <td class="cell" id="Td2">
        <h3>   <%= Model._Forming %></h3> 
         </td>
      </tr>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P1))
         { %>
      <tr class="rowb">
         <td class="col" style="p width: 25%;">
            P1
          
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 1 (มม.)</span>
         </td>
         <td class="cell" id="Td3">
     <h3>  <%= Model._P1%></h3>     
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P2))
         { %>
      <tr class="rowb">
         <td class="col" style="p width: 25%;">
            P2
            
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 2 (มม.)</span>
         </td>
         <td class="cell" id="Td4">
        <h3>   <%= Model._P2%></h3> 
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P3))
         { %>
      <tr class="rowb">
         <td class="col" style="p width: 25%;">
            P3
         
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 3 (มม.)</span>
         </td>
         <td class="cell" id="Td5">
           <h3> <%= Model._P3%></h3>
         </td>
      </tr>
      <% } %>
      <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._P4))
         { %>
      <tr class="rowb">
         <td class="col" style=" width: 25%;">
            P4
          
            <span class="fontTh">ความยาวผ้าใบชั้นที่ 4 (มม.)</span>
         </td>
         <td class="cell" id="Td6">
          <h3> <%= Model._P4%></h3> 
         </td>
      </tr>
      <% } %>
      <tr class="rowb">
         <td class="col" style=" width: 25%;">
            Topped Cord
            
            <span class="fontTh">ผ้าใบ</span>
         </td>
         <td class="cell" id="Td7">
         <h3>  <%= Model._Topcrdcd%></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col" style=" width: 25%;">
            Tire Cord Lot<span class="fontTh"> 
             ล็อตผ้าใบ</span>
         </td>
         <td class="cell" id="Td8">
         <h3>  <%= Model._tcrdlot %></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col" style=" width: 25%;">
            Roll No
          
            <span class="fontTh">รถคันที่</span>
         </td>
         <td class="cell" id="Td9">
         <h3>  <%= Model._toproll %></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col" style=" width: 25%;">
           Expired date
       
            <span class="fontTh">วันหมดอายุ</span>
         </td>
         <td class="cell">
         <h3>  <%= Model._topexp %></h3> 
         </td>
      </tr>
      <tr class="rowb">
         <td class="col" style=" width: 25%;">
         Length (M.)
            
            <span class="fontTh">ความยาว(เมตร)</span>
         </td>
         <td class="cell" >
         <h3>  <%= Model._toplen %></h3> 
         </td>
      </tr>
   </table>

</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
   <section class="featured">
 <div class="content-wrapper" style="height:40px">
            <hgroup class="title float-left">
            <h1>Bias Head Computer</h1>
                <h2  style="padding-left:55px;">BIAS NO.<%: Model._Biasno %></h2>      
             
            </hgroup> 
             <hgroup class="title float-right">
                <h3>
         Name :
         <% if (Request.IsAuthenticated)
         { %>
         <%:  User.Identity.Name %>
         <% } %></h3>
            </hgroup>   
 </div>
 </section>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="TableContent" runat="server">
<div style="clear: left; margin-top: 15px; ">
<% if(WinNemoLib.StrUtil.IsEmpty(Model._Actflag) ||  Convert.ToInt64( Model._Actflag) <= 0) { %>

     <div class="float-left" style="margin-left: 50px;">
          <input type="button" id="back" value="BACK" class="btnFooter"  
              style="height: 75px;  width: 350px;" />
        
      </div> 
      
       <% } %>
      <div style="float: right; margin-right: 35px;">
        <input id="next" type="button" value="NEXT" class="btnFooter" 
              style="height: 75px; width: 350px;" />
      </div>
    
   </div>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="ScriptsSection" runat="server">
<% if (false)
   { %>
<script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<% } %>
<script type="text/javascript">


    $(function () {

        function callScriptMethod(url, jsonObject, action, callback, async) {

            callback = callback || function () { };
            async = (async == null || async);

            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: url,
                data: JSON.stringify(jsonObject),
                dataType: "json",
                async: async,
                success: function (data) {

                    if (data.success != "0") {
                        var getUsersUrl = '<%= Url.Action("Use_KANBAN","BiasHead_KANBAN") %>' + '?seq=' + $.trim($("#seqDT").text()) + '&biasno=' + '<%: Model._Biasno %>' + '&shift=' + '<%: Model._Shift %>';

                        window.location = getUsersUrl;
                    } else alert(data.message);
                },
                error: function (xhr, status, error) {
                    var err = xhr.responseText;
                    alert(err.Message);
                }
            });
        }

        var seq = '<%= Model._Plandt %>' + '-' + '<%= Model._Itemno %>';
        $.post('<%=Url.Action("GET_USE","BiasHead")%>' + '?seq=' + seq + '&biasno=' + '<%= Model._Biasno %>', function (data) {
            if (data.length > 0) {
                $("#sumP1").text(data[0]._P1);
                $("#sumP2").text(data[0]._P2);
                $("#sumP3").text(data[0]._P3);
                $("#sumP4").text(data[0]._P4);
                var total = parseFloat(data[0]._P1) + parseFloat(data[0]._P2) + parseFloat(data[0]._P3) + parseFloat(data[0]._P4);
                if (total > 0) {
                    $("#back").attr("disabled", "disabled");
                }
                $("#total").text(total);

            }
        });
        $("#next").click(function () { Savedata() });

        function Savedata() {

            if ($(".active").length < 1) {
                return;
            }
            var P1 = null;
            var P2 = null;

            if ($(".active").length > 1) {
                P1 = $(".active:first").val();
                P2 = $(".active:eq(1)").val();
            } else {
                P1 = $(".active:first").val();
            }
            var dataForSubmit = new Array();
            dataForSubmit.push({
                _biasno: '<%: ViewBag.biasno %>',
                _plandt: '<%: Model._Plandt %>',
                _itemno: '<%: Model._Itemno %>',
                _empname: '<%: User.Identity.Name %>',
                _Ply1: P1,
                _Ply2: P2,
                _shift: '<%: Model._Shift %>'
            });
            var getUsersUrl = '<%= Url.Action("SAVE_SUB_ITEM") %>';

            callScriptMethod(getUsersUrl, { theData: dataForSubmit }, 'ADD');
        }


        $("#back").click(function () {

            var url = '<%= Url.Action("RollBack","BiasHead") %>' + '?seq=' + '<%= Model._Plandt %>' + "-" + '<%=Model._Itemno %>';
            url = url + "&biasno=" + '<%: Model._Biasno %>' + '&shift=' + '<%: Model._Shift %>';
            window.location = url;
        });

        $(".chk").click(function () {

            if ($(this).hasClass('active')) {
                $(this).removeClass('active');
            } else {
                if ($(".active").length > 1) {
                    return;
                }
                $(this).addClass('active');
            }
        });



    })

</script>
</asp:Content>
